package com.itheima.admin.controller;

import com.itheima.admin.service.IDeptService;
import com.itheima.admin.service.IModuleService;
import com.itheima.pojo.Config.Result;
import com.itheima.pojo.dto.ModuleDto;
import com.itheima.pojo.dto.UserDto;
import com.itheima.pojo.vo.ModuleVo;
import com.itheima.pojo.vo.UserVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/module")
public class ModuleController {
    @Autowired
    private IModuleService moduleService;

    @GetMapping("/{id}")
    @ApiOperation("根据id查询用户")
    public ModuleVo queryById(@PathVariable("id") String id) {
        return moduleService.queryById(id);
    }

    @PutMapping("/edit")
    public Result updateModule(@RequestBody ModuleDto moduleDto) {
        boolean flag = moduleService.updateModule(moduleDto);

        Result result = Result.builder()
                .flag(flag)
                .data(null)
                .message(flag ? "修改模块成功!" : "修改模块失败!")
                .build();
        return result;
    }
}
